package org.mq.mymq.broker.config;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName CommonThreadPoolConfig
 * @Description 通用线程池配置
 * @Author jiarong_ye
 * @Date 2025/6/16 11:36
 * @Version 1.0
 */
public class CommonThreadPoolConfig {
    // 异步刷盘topic配置
    public static ThreadPoolExecutor refreshMyMqTopicExecutor = new ThreadPoolExecutor(1, 1, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Thread thread = new Thread(r);
            thread.setName("refresh-my-mq-topic-config");
            return thread;
        }
    });
    // 异步刷盘comsumer消费进度配置
    public static ThreadPoolExecutor refreshConsumerQueueOffsetExecutor = new ThreadPoolExecutor(1, 1, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Thread thread = new Thread(r);
            thread.setName("refresh-my-mq-consumer-config");
            return thread;
        }
    });
}
